<template>
  <div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      class="j-table-force-nowrap"
      :scroll="{ x: true }"
      :columns="outboundColumns"
      :dataSource="outboundList"
    >
    </a-table>
  </div>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction } from '@api/manage'

export default {
  name: 'outbound',
  data() {
    return {
      description: '材料出库信息',
      outboundList: [],
      outboundColumns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 40,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '出库类型',
          align: 'center',
          dataIndex: 'outboundType_dictText',
        },
        {
          title: '单据号',
          align: 'center',
          dataIndex: 'documentNumber',
        },
        {
          title: '出库单号',
          align: 'center',
          dataIndex: 'outboundNumber',
        },
        {
          title: '客户名称',
          align: 'center',
          dataIndex: 'customerName',
        },
        {
          title: '客户物料编码',
          align: 'center',
          dataIndex: 'customerMaterialCode',
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode',
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName',
          width: 120,
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'specificationModel',
        },
        {
          title: '主计量单位',
          align: 'center',
          dataIndex: 'unit_dictText',
        },
        {
          title: '主数量',
          align: 'center',
          dataIndex: 'quantity',
        },
        {
          title: '辅计量单位',
          align: 'center',
          dataIndex: 'secondaryUnit_dictText',
        },
        {
          title: '辅数量',
          align: 'center',
          dataIndex: 'secondaryQuantity',
        },
        {
          title: '库存可用数量',
          align: 'center',
          dataIndex: 'availableInventory',
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createBy_dictText',
        },
        {
          title: '制单人部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText',
        },
        {
          title: '制单日期',
          align: 'center',
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
        },
      ],
      url: {
        list: '/wms/outbound/outbound-record/list',
      },
    }
  },
  methods: {
    loadOutboundData(batchNumber, convert) {
      this.outboundList = []
      if (batchNumber) {
        let params = { pageSize: 999, pageNo: 1 }
        if (convert) {
          params.planNumber = batchNumber
        } else {
          params.batchNumber = batchNumber
        }
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.outboundList = res.result.records || res.result || []
          }
        })
      }
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
::v-deep .ant-table-tbody tr {
  height: 36px !important;
}
</style>
